<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <title>管理平台</title>
    <link rel="stylesheet" href="${base}/static/layui/css/layui.css"/>
    <link rel="stylesheet" href="${base}/static/css/admin.css"/>
</head>
<body>
    <form class="layui-form" id="adminform" action="${base}/goods/saveGoods">
	    <table class="layui-table layui-table-add" lay-skin="nob">
		  <tbody>
		  <tr>
			  <input type="hidden" name="goodsId" value="${goods.id!}" />
		      <th width="100"><span class='red'>*</span>产品</th>
		      <td>
				  <div style="width:30%">
				  <input type="text" name="name" value="${goods.name!}" placeholder="产品名称" autocomplete="off" class="layui-input"></td>
			</div>
			</tr>

		    <tr>
		      <th><span class='red'>*</span>价格</th>
		      <td>
		        <div style="width:30%">
		        	<input type="text" name="price" value="${goods.price!}" placeholder="产品价格" autocomplete="off" class="layui-input">
		        </div>
		      </td>
		    </tr>

			<tr>
				<th><span class='red'>*</span>库存</th>
				<td>
					<div style="width:30%">
						<input type="text" name="num" value="${goods.num!}" placeholder="库存" autocomplete="off" class="layui-input">
					</div>
				</td>
			</tr>
		  </tbody>
		</table>
		<div style="margin-left: 145px; margin-bottom: 15px;">	
			<div class="layui-btn" id="adminBut" style=" min-width: 150px;">提 交</div>
		</div>
	</form>

	<script type="text/javascript" src="${base}/static/layui/jquery.min.js"></script>
	<script type="text/javascript" src="${base}/static/layui/layui.js"></script>
	<script type="text/javascript" src="${base}/static/js/jquery.form.js"></script>
	<script type="text/javascript" src="${base}/static/js/util.js"></script>
	<script>
        $("#adminBut").click(function() {
          $("#adminform").ajaxSubmit({
                clearForm: false,
                dataType: "JSON",
                success: function(data) {
                    if(data.code==200){
                        layer.msg('添加成功！',{time: 2000});
                        closeThisWindowAndParentReload(1500);
                    }else if(data.code==300){
                        layer.msg(data.message,{time: 2000});
                        closeThisWindowAndParentReload(1500);
					}else{
                        layer.msg(data.message,{time: 2000});
					}
                },
                error: function(){
                    layer.msg('添加失败！',{time: 1000});
				}
        });
        });
		layui.use(['jquery','form','upload','layer'], function(){
            var $ = layui.jquery
                ,layer = layui.layer
                ,form = layui.form();

            $("#adminform").submit(function(e){
                layui.upload({
                    url: ''
                    ,success: function(res){
                        console.log(res); //上传成功返回值，必须为json格式
                    }
                });
            });

			layer.photos({
			  photos: '#layer-photos-demo'
			  ,closeBtn: 1
			  ,anim: 0 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
			}); 


			// 删除操作
		    $(document).on("click", ".del", function() {
			    layer.open({
			      title:"删除操作"
				  ,content: '您确认要删除该属性商品吗？'
				  ,btn: ['取消', '确认']
				  ,yes: function(index, layero){
				       layer.closeAll();
				  }
				  ,btn2: function(index, layero){
				      layer.msg('删除成功！',{time: 1000});
				  }
				});
			});
		});
	</script>
</body>
</html>